import java.util.*;

public class Text{
    public int singleNumber(int[] nums) {
        Set<Integer> hashset = new HashSet();
        for(int i = 0;i < nums.length ; i++){
            if(!hashset.contains(nums[i])) {
                hashset.add(nums[i]);
            }else{
                hashset.remove(nums[i]);
            }
        }
        for(int i=0;i<nums.length;i++){
            if(hashset.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }
    public static void main(String[] args) {
        BinarySearchTree searchTree = new BinarySearchTree();
        searchTree.insert(20);
        searchTree.insert(50);
        searchTree.insert(10);
        searchTree.insert(5);
        searchTree.insert(15);
        searchTree.insert(60);
        searchTree.insert(3);
        System.out.println(searchTree.search(3).key);
        searchTree.remove(10);
        System.out.println("fasd");

    }
    public static void main1(String[] args) {
        int[] array = {1,3,4,5,7,4,8,6,3,9};

        Map<Integer,Integer> hashMap = new HashMap<>();
        for (int i = 0; i < array.length; i++) {
            if(!hashMap.containsKey(array[i])) {
                hashMap.put(array[i],1);
            }else{
                hashMap.put(array[i],hashMap.get(array[i])+1);
            }
        }
        System.out.println(hashMap);

    }
    private static int partition (int[] array,int left,int right) {
        int temp = left;
        while(left < right){
            while(left < right && array[right] < array[temp]) {
                right--;
            }
            while(left < right && array[left] > array[temp]) {
                left++;
            }
            int tmp = array[left];
            array[left] = array[right];
            array[right] = tmp;
        }
        int tmp = array[temp];
        array[temp] = array[right];
        array[right] = tmp;
        return left;
    }
}
